import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }
        boolean flag = false;
        for (int i = 0; i < arr.length-2; i++) {
            if (arr[i] % 2 != 0&&arr[i+1] % 2 != 0&&arr[i+2] % 2 != 0) {
                flag = true;
                break;
            }
        }
        System.out.println(flag);
    }
}